package com.lsmgc.cms.util.upload;

import org.apache.commons.fileupload.FileItem;

import java.io.File;

/**
 * 文件工具类
 */
public class FileUtils {
    /**
     * 文件保存路径
     */
    public static final String SAVE_PATH = "E:/upload/";

    /**
     * 保存文件
     * @param fileItem 文件内容
     * @param path 保存路径
     * @return
     * @throws Exception
     */
    public static String saveFile(FileItem fileItem, String path) throws Exception {
        String fileName = System.currentTimeMillis() + "_" + fileItem.getName();
        fileItem.write(new File(path + fileName));
        return fileName;
    }
}
